package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.smartelderlycare.dao.SysPharmMapper;
import com.jk.smartelderlycare.dto.SysPharm;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.service.SysPharmService;
import com.jk.smartelderlycare.utils.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysPharmServiceImpl
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/7 17:32
 */
@Service
public class SysPharmServiceImpl implements SysPharmService {
    @Autowired
    private  SysPharmMapper sysPharmMapper;
    /**
     * @description: 药品列表后端分页查询
     * @param: [sysPharm, pageNum, pageSize]
     * @return: com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysPharm>
     * @author hhk
     * @date: 2024/11/7 18:51
     */
    @Override
    public PagedResponse<SysPharm> findSysPharmPaginationList(SysPharm sysPharm, Integer pageNum, Integer pageSize) {
        Page<SysPharm> page = new Page<>(pageNum, pageSize);
        IPage<SysPharm> sysPharmList =  sysPharmMapper.findSysPharmPaginationList(sysPharm,page);
        return PaginationUtil.getPagedResponse(sysPharmList.getRecords(),pageNum,pageSize,sysPharmList.getTotal());
    }
    /** 
     * @description: 新增药品列表信息
     * @param: [sysPharm]
     * @return: void
     * @author hhk
     * @date: 2024/11/7 18:57
     */ 
    @Override
    public void addSysPharm(SysPharm sysPharm) {
        sysPharmMapper.insert(sysPharm);
    }
    /**
     * @description: 根据id删除一条数据信息
     * @param: [pharmId]
     * @return: void
     * @author hhk
     * @date: 2024/11/7 18:58
     */
    @Override
    public void deleteSysPharmByPharmId(Long pharmId) {
        sysPharmMapper.deleteById(pharmId);
    }
    /**
     * @description: 根据id回显一条数据信息
     * @param: [pharmId]
     * @return: com.jk.smartelderlycare.dto.SysPharm
     * @author hhk
     * @date: 2024/11/7 18:58
     */
    @Override
    public SysPharm findSysPharmByPharmId(Long pharmId) {
        return sysPharmMapper.selectById(pharmId);
    }
    /**
     * @description: 修改药品数据列表
     * @param: [sysPharm]
     * @return: void
     * @author hhk
     * @date: 2024/11/7 18:59
     */
    @Override
    public void updateSysPharm(SysPharm sysPharm) {
        sysPharmMapper.updateById(sysPharm);
    }
    /**
     * @description: 状态修改
     * @param: [sysPharm]
     * @return: void
     * @author hhk
     * @date: 2024/11/7 18:59
     */
    @Override
    public void updateStatusById(SysPharm sysPharm) {
        sysPharmMapper.updateStatusById(sysPharm);
    }
}
